//获取Token
export const getToken = () => {
	try {
		const value = uni.getStorageSync('token');
		return value ? value : '';
	} catch (e) {
		throw new Error(e)
	}
}
//验证是否授权
export const getSetting = () => {
	uni.getSetting({
		success: (res) => {
			let setting = res.authSetting['scope.userInfo']
			uni.setStorageSync('setting', setting)
		}
	})
}
//登录
export const getCode = () => {
	uni.login({
		provider: 'weixin',
		success: (res) => {
			uni.setStorageSync('code', res.code)
		}
	})
}
//获取选项卡选中后的值
export const getDrop = (v, array) => {
	return array.filter((val) => {
		return val.value === v ? val.label : ''
	})[0].label
}

//处理筛选栏三级联动的简短显示
export const setFilterHead = (param) => {
	console.log(param)
	let p = param.province
	let c = param.city
	let a = param.area.substr(0, param.area.length - 1)
	if (c == '市辖区' || c == '特别行政区') {
		return p + a
	} else {
		return p + c + a
	}
}
